package handler

import (
	"api/config"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	seckill "seckill/proto"
)

type ServerInterface interface {
	SecKillServer(addr *string)
}

type ServerConfig struct {
}

func NewClient() *ServerConfig {
	return &ServerConfig{}
}

func Init(addr *string) *grpc.ClientConn {
	conn, _ := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	return conn
}

func (ServerConfig) SecKillServer(addr *string) {
	init := Init(addr)
	config.SecKillSrv = seckill.NewSeckillClient(init)
}
